package com.simpleim.starter.protoBuilder;

import com.simpleim.im.common.bean.User;
import com.simpleim.im.common.bean.msg.ProtoMsg;
import com.simpleim.starter.client.ClientSession;

public class HeartBeatMsgBuilder extends BaseBuilder{

    private User user;

    private HeartBeatMsgBuilder(User user, ClientSession session) {
        super(ProtoMsg.HeadType.HEART_BEAT, session);
        this.user = user;
    }

    private ProtoMsg.Message build() {
        ProtoMsg.Message message = buildCommon(-1);
        ProtoMsg.MessageHeartBeat.Builder lb =
                ProtoMsg.MessageHeartBeat.newBuilder()
                        .setSeq(0)
                        .setJson("{\"from\":\"client\"}")
                        .setUid(user.getUid());
        return message.toBuilder().setMessageHeartBeat(lb).build();
    }

    public static ProtoMsg.Message buildMsg(User user, ClientSession session) {
        return new HeartBeatMsgBuilder(user, session).build();
    }

}
